#include<stdio.h>

#define N 10

void swap_m(int arr[], int n);
int main(int argc, char *argv[])
{
	int arr[N] = {0};

	printf("请输入10个整数：");
	for(int i = 0; i < N; i++){
		scanf("%d", &arr[i]);
	}

	swap_m(arr, N);
	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");

	return 0;
}

void swap_m(int arr[], int n){
	int i;
	int max;
	int min;
	int tem;

	for(i = 1, max = 0, min = 0; i < n; i++){
		if(arr[i] > arr[max]){
			max = i;
		}
	   	if(arr[i] < arr[min]){
			min = i;
		}
	}
	if(0 != max){
		tem = arr[0];
		arr[0] = arr[max];
		arr[max] = tem;
	}

	if(0 == min)//很关键{
 		min = max;
	}

	if((n-1) != min){
		tem = arr[n-1];
		arr[n-1] = arr[min];
		arr[min] = tem;
	}
	return;

}
